package com.ibeeking.found.msg.rest.controller.v1;

import com.ibeeking.found.common.constants.WxOpenServiceTypeConstant;
import com.ibeeking.found.common.entity.open.OpenAuthDTO;
import com.ibeeking.found.common.enums.OpenApiConfigEnum;
import com.ibeeking.found.common.enums.WxOpenAppTypeEnum;
import com.ibeeking.found.common.utils.UserUtils;
import com.ibeeking.found.msg.rest.service.IOpenService;

import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName MpController控制器
 * @Description
 * @Author ibeeking
 * @Date 2020-12-30 14:12
 **/
@RestController
@RequestMapping("/b/wxMp/v1")
public class WxMpController {

    @Resource
    private IOpenService wxOpenServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询有效的公众号账号")
    @PostMapping(value = "/checkVaildWxMp")
    public OpenAuthDTO checkVaildWxMp(){
        Long tenantId = UserUtils.getTenantID();
        return wxOpenServiceImpl.queryWxOpenAuthByTenantId(tenantId,
                OpenApiConfigEnum.OPEN_CONFIG_TYPE_WECHAT_OPEN.getCode(),
                WxOpenAppTypeEnum.WECHAT_OPEN_APP_TYPE_MP.getCode(),
                WxOpenServiceTypeConstant.APPID_TYPE_MP);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询有效的公众号账号")
    @PostMapping(value = "/checkVaildWxMa")
    public OpenAuthDTO checkVaildWxMa(){
        Long tenantId = UserUtils.getTenantID();
        return wxOpenServiceImpl.queryWxOpenAuthByTenantId(tenantId,
                OpenApiConfigEnum.OPEN_CONFIG_TYPE_WECHAT_OPEN.getCode(),
                WxOpenAppTypeEnum.WECHAT_OPEN_APP_TYPE_MA.getCode(),
                WxOpenServiceTypeConstant.APPID_TYPE_MINI);
    }
}
